<?php
	include './header.php';

	$sql_goods="select
					g.id        gid,
					g.name      gname,
					g.is_hot    ghot,
					g.is_bast   gbast,
					g.price     gp,
					gi.name     giname
				from
					goods       g,
					goods_img   gi
				where
					g.id=gi.goods_id
				and
					gi.is_cover=1
				and
					g.is_bast=1
				";
	$hot=[];
	$goods_list=$goods_model->find($sql_goods);
	if (!empty($goods_list)) 
	{
		foreach ($goods_list as $k => $v) 
		{
			if ($v['ghot']=1) 
			{
				$hot[]=$v;
			}
		}
	}
	if (!empty($hot)) 
	{
		foreach ($hot as $ke => $val) 
		{
			$hot[$ke]['giname']=URL.'/public/uploads/'.substr($val['giname'], 0,4).'/'.substr($val['giname'], 4,2).'/'.substr($val['giname'], 6,2).'/300_'.$val['giname'];
		}
	}
?>
<div class="clear"></div>
<div id="main">
	<!--遍历热销商品-->
	<div class="hot_nav">
		<span>热销商品</span>
	</div>
	<div class="hot_h">
		<?php if (!empty($hot)) :?>
			<ul>
				<?php foreach ($hot as $h => $ho) :?>
					<div class="ji">
					<li>
					<a href="<?php echo URL;?>/detail.php?id=<?php echo $ho['gid'];?>">
					<img src="<?php echo $ho['giname'];?>" alt="美工回家生娃了" ><br/>
					<span style="color:#000;"><?php echo $ho['gname'];?></span></a><br/>
					<span style="color:red;">¥:<?php echo $ho['gp'];?></span>
					</li>
					</div>
				<?php endforeach;?>			
			</ul>
		<?php else :?>	
				<div>没有热销商品</div>
		<?php endif;?>
	</div>
	<div class="clear"></div>
</div>

<?php 
	include PATH.'/footer.php';
?>